#!/bin/bash

TESTHOST="$1"
TESTPORT="$2"
TESTUSER="postgres"
OPTS=""

[[ -d /usr/local/pgsql/bin ]] && PATH=/usr/local/pgsql/bin:$PATH 

export PGHOST="$TESTHOST"
export PGPORT="$TESTPORT"
export PGUSER="$TESTUSER"
export PGPASSWORD="postgres"

dropdb $OPTS pgbench
dropdb $OPTS results

createdb $OPTS pgbench
createdb $OPTS results

pgbench -r -i -s 20 pgbench
pgbench -c 1 -T 30 pgbench

dropdb $OPTS pgbench
dropdb $OPTS results

